
#import "Indicator.h"
#import <dpsclient/wraps.h>
#import <appkit/Application.h>

@implementation Indicator

- initFrame:(NXRect *)frameRect
{
	[super initFrame:frameRect];
	on=NO;
	return self;
}

- drawSelf:(NXRect *)rects :(int)count
{
	if (on)
		PSsetrgbcolor(1,0,0);
	else
		PSsetgray(NX_WHITE);
	NXRectFill(&bounds);
	PSsetgray(NX_BLACK);
	NXFrameRect(&bounds);
	return self;
}
		
- flash
{
	void endLight ();
	on=YES;
	[self display];
    if (timer) DPSRemoveTimedEntry(timer);
    timer=DPSAddTimedEntry(.2,&endLight,self,NX_BASETHRESHOLD);
	return self;
}

- turnOff
{
	on=NO;
	[self display];
	return self;
}

void endLight (DPSTimedEntry timedEntry, double timeNow, void *data)
{
	[(id)data turnOff];
}


@end
